// LogRecordDao.java
package no.nordicsemi.android.nrfmesh.database.dao;

import androidx.lifecycle.LiveData;
import androidx.room.*;

import java.util.List;
import no.nordicsemi.android.nrfmesh.database.entity.LogRecord;

@Dao
public interface LogRecordDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    long insertLogRecord(LogRecord record); // 返回插入记录的ID

    @Query("SELECT * FROM log_records ORDER BY startTime DESC")
    LiveData<List<LogRecord>> getAllLogRecords();

    @Query("SELECT * FROM log_records ORDER BY startTime DESC")
    List<LogRecord> getAllLogRecordsSync(); // 添加同步查询方法

    @Query("SELECT * FROM log_records WHERE id = :id LIMIT 1")
    LogRecord getLogRecordById(int id);

    @Delete
    void deleteLogRecord(LogRecord logRecord);
}